package com.hentie.spritedrawlib;

import java.util.HashMap;
import java.util.Map;

import android.content.Context;

import com.hentie.spritelib.SpriteData;
import com.hentie.spritelib.SpriteXMLParser;

public class SpriteFactory {
	
	public static Map<String,SpriteData> spriteMap = new HashMap<String,SpriteData>();
	
	public static Sprite CreateSprite(Context context, String spriteXML)
	{
		//Tr to find it in the map
		if(spriteMap.containsKey(spriteXML)==true)
			return new Sprite(context,SpriteFactory.spriteMap.get(spriteXML));
		else
		{
			//Add it to the map
			SpriteFactory.spriteMap.put(spriteXML, SpriteXMLParser.ParseXML(context, spriteXML));
			return new Sprite(context,SpriteFactory.spriteMap.get(spriteXML));
		}
	}
	

}
